package cn.edu.dlut.port.isp.bean.teach.simulation;

import arjuna.javasims.dist.RandomStream;
import cn.edu.dlut.port.optiplan.elem.Berth;
import cn.edu.dlut.port.optiplan.elem.Current;
import cn.edu.dlut.port.optiplan.elem.Ship;
import cn.edu.dlut.port.optiplan.elem.Soil;
import cn.edu.dlut.port.optiplan.elem.Terminal;
import cn.edu.dlut.port.optiplan.elem.Tide;
import cn.edu.dlut.port.optiplan.elem.Wave;
import java.util.ArrayList;
import java.util.Iterator;

/**
 *
 * @author tangguolei
 */
public class PortBean {

    private int id;
    private ArrayList<BerthBean> berths;
    private String name;
    private double operationalDay;
    private TideBean tideBean;
    private double waveHeight;
    private double wavePeriod;
    private double crossCurrentV;
    private double longitudinalCurrentV;
    private int depoistState;
    private String portLayoutJPG;
    private String geoJPG;
    private double waveAngle;
    private double vsame;

    public ArrayList<BerthBean> getBerths() {
        return berths;
    }

    public void setBerths(ArrayList<BerthBean> berths) {
        this.berths = berths;
    }

    public double getCrossCurrentV() {
        return crossCurrentV;
    }

    public void setCrossCurrentV(double crossCurrentV) {
        this.crossCurrentV = crossCurrentV;
    }

    public double getLongitudinalCurrentV() {
        return longitudinalCurrentV;
    }

    public void setLongitudinalCurrentV(double longitudinalCurrentV) {
        this.longitudinalCurrentV = longitudinalCurrentV;
    }

    public double getOperationalDay() {
        return operationalDay;
    }

    public void setOperationalDay(double operationalDay) {
        this.operationalDay = operationalDay;
    }

    public double getWaveHeight() {
        return waveHeight;
    }

    public void setWaveHeight(double waveHeight) {
        this.waveHeight = waveHeight;
    }

    public double getWavePeriod() {
        return wavePeriod;
    }

    public void setWavePeriod(double wavePeriod) {
        this.wavePeriod = wavePeriod;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public TideBean getTideBean() {
        return tideBean;
    }

    public void setTideBean(TideBean tide) {
        this.tideBean = tide;
    }

    public String getPortLayoutJPG() {
        return portLayoutJPG;
    }

    public void setPortLayoutJPG(String portLayoutJPG) {
        this.portLayoutJPG = portLayoutJPG;
    }

    public String getGeoJPG() {
        return geoJPG;
    }

    public void setGeoJPG(String geoJPG) {
        this.geoJPG = geoJPG;
    }

    public double getWaveAngle() {
        return waveAngle;
    }

    public void setWaveAngle(double waveAngle) {
        this.waveAngle = waveAngle;
    }

    public int getDepoistState() {
        return depoistState;
    }

    public void setDepoistState(int depoistState) {
        this.depoistState = depoistState;
    }
//参数有问题
   public Soil getSoil() {
       return new Soil(true);
	  // return new Soil(this.depoistState);
    }

    public Tide getTide() {
        return tideBean.toTide();
    }

    public Wave getWave() {
        return new Wave(1.5, wavePeriod, waveAngle);
    }

    public Current getCurrent() {
        return new Current(this.crossCurrentV, this.longitudinalCurrentV);
    }

    public Terminal toTerminal() {
        int no = 1;
        int noj = 0;
        Terminal terminal = new Terminal();
        Ship designedships[] = new Ship[berths.size()];
        for (Iterator<BerthBean> it = berths.iterator(); it.hasNext();) {
            BerthBean berthInfo = it.next();
            int num = berthInfo.getNumber();
            designedships[noj] = ConfInfoUtil.getDesignedShip(berthInfo.getCargoTypeInt(), berthInfo.getTonnage(), vsame);
            for (int i = 0; i < num; i++) {
                Berth berth = new Berth(no + "#", operationalDay, 0.8, designedships[noj]);
                double m = 24 / berth.averageArrivingShipsPerBerthAndDay();
                RandomStream random = RandomStream.random(RandomStream.EXPO, m);
                berth.setRandom(random);
                terminal.add(berth);
                no++;
            }
            noj++;
        }
        return terminal;
    }

/*    @Override
    public String toString() {
        return this.getId() + "\t" + this.getName() + "\t" + this.getOperationalDay();
    }*/

    public double getV() {
        return vsame;
    }

    @Override
	public String toString() {
		return "PortBean [id=" + id + ", berths=" + berths + ", name=" + name + ", operationalDay=" + operationalDay
				+ ", tideBean=" + tideBean + ", waveHeight=" + waveHeight + ", wavePeriod=" + wavePeriod
				+ ", crossCurrentV=" + crossCurrentV + ", longitudinalCurrentV=" + longitudinalCurrentV
				+ ", depoistState=" + depoistState + ", portLayoutJPG=" + portLayoutJPG + ", geoJPG=" + geoJPG
				+ ", waveAngle=" + waveAngle + ", vsame=" + vsame + "]";
	}

	public void setV(double v) {
        this.vsame = v;
    }
}
